home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWTValHashSetIterator.z / RWTValHashSetIterator
Encoding:
Text File  |  1998-10-30  |  8.2 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTValHashSetIterator<T,H,EQ> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tvhset.h>
  13.  
  14.  
  15.  
  16.               RWTValHashSet<T,H,EQ> m;
  17.           RWTValHashSetIterator<T,H,EQ> itr(m);
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
  25.      IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee....
  26.      OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee rrrreeeessssttttrrrriiiicccctttteeeedddd iiiinnnntttteeeerrrrffffaaaacccceeee ttttoooo RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhTTTTaaaabbbblllleeeeIIIItttteeeerrrraaaattttoooorrrr
  27.      described in Appendix A.
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  35.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7 to provide an iterator
  36.      interface to RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr that is backward compatible with the
  37.      container iterators provided in TTTToooooooollllssss....hhhh++++++++ 6.x. Iteration over an
  38.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeetttt is pseudorandom and dependent on the capacity of the
  39.      underlying hash table and the hash function being used.  The only useable
  40.      relationship between consecutive elements is that elements which are
  41.      defined to be equivalent by the equivalence object, EEEEQQQQ, will remain
  42.      adjacent.  The current item referenced by this iterator is undefined
  43.      after construction or after a call to rrrreeeesssseeeetttt(((()))).  The iterator becomes
  44.      valid after being advanced with either a pre-increment or an ooooppppeeeerrrraaaattttoooorrrr(((()))).
  45.      For both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last element will
  46.      return a value equivalent to boolean ffffaaaallllsssseeee.  Continued increments will
  47.      return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is called.
  48.  
  49. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  50.      None
  51.  
  52. EEEExxxxaaaammmmpppplllleeee
  53.               #include<rw/tvhset.h>
  54.  
  55.  
  56.  
  57.               #include<rw/cstring.h>
  58.           #include<iostream.h>
  59.           struct silly_h{
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.              unsigned long operator()(const RWCString& x) const
  75.              { return x.length() * (long)x(0); }
  76.           };
  77.           int main(){
  78.              RWTValHashSet <RWCString, silly_h,equal_to<RWCString> > age;
  79.              RWTValHashSetIterator
  80.                <RWCString, silly_h, equal_to<RWCString > > itr(age);
  81.              age.insert("John");
  82.              age.insert("Steve");
  83.              age.insert("Mark");
  84.           //Duplicate insertion rejected
  85.              age.insert("Steve");
  86.              for(;itr();) cout << itr.key() << endl;
  87.              return 0;
  88.           }
  89.           Program Output (not necessarily in this order)
  90.           John
  91.           Steve
  92.  
  93. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  94.      Mark
  95.  
  96.  
  97.  
  98.               RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr<<<<TTTT,,,,HHHH,,,,EEEEQQQQ>>>> (RWTValHashSet<T,H,EQ>&h);
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.      Creates an iterator for the hashset hhhh.  The iterator begins in an
  106.      undefined state and must be advanced before the first element will be
  107.      accessible.
  108.  
  109. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  110.               RWBoolean
  111.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  112.  
  113.  
  114.      Advances sssseeeellllffff to the next element.  Returns ffffaaaallllsssseeee if the iterator has
  115.      advanced past the last item in the container and ttttrrrruuuueeee otherwise.
  116.  
  117.               RWBoolean
  118.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  119.  
  120.  
  121.      Advances sssseeeellllffff to the next element.  If the iterator has been reset or
  122.      just created sssseeeellllffff will now reference the first element.  If, before
  123.      iteration, sssseeeellllffff referenced the last value in the multi-set, sssseeeellllffff will now
  124.      reference an undefined value and ffffaaaallllsssseeee will be returned.  Otherwise, ttttrrrruuuueeee
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      is returned.  Note: no postincrement operator is provided.
  141.  
  142. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  143.               RWTValHashSet<T,H,EQ>*
  144.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  145.  
  146.  
  147.      Returns a pointer to the collection being iterated over.
  148.  
  149.               T
  150.           kkkkeeeeyyyy() const;
  151.  
  152.  
  153.      Returns the value currently pointed to by sssseeeellllffff.
  154.  
  155.               void
  156.           rrrreeeesssseeeetttt();
  157.           void
  158.           rrrreeeesssseeeetttt(RWTValHashSet<T,H,EQ>& h);
  159.  
  160.  
  161.      Resets the iterator so that after being advanced it will reference the
  162.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  163.      reset the iterator on the current container.  Supplying a RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhSSSSeeeetttt
  164.      to rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.